home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / processes / exec next >
Encoding:
Text File  |  1993-10-26  |  7.9 KB  |  153 lines  |  [TEXT/$Tcl]

  1.  
  2.           exec ?switches? arg ?arg ...?
  3.  
  4.  
  5.      DESCRIPTION
  6.           This command treats its arguments as  the  specification  of
  7.           one or more subprocesses to execute.  The arguments take the
  8.           form of a standard shell pipeline where each arg becomes one
  9.           word  of a command, and each distinct command becomes a sub-
  10.           process.
  11.  
  12.           If the initial arguments to exec start with - then they  are
  13.           treated  as  command-line  switches  and are not part of the
  14.           pipeline  specification.    The   following   switches   are
  15.           currently supported:
  16.  
  17.           -keepnewline Retains a trailing newline  in  the  pipeline's
  18.                        output.   Normally  a  trailing newline will be
  19.                        deleted.
  20.  
  21.           --           Marks the end of switches.  The  argument  fol-
  22.                        lowing  this  one  will be treated as the first
  23.                        arg even if it starts with a -.
  24.  
  25.           If an arg (or pair of arg's) has one of the forms  described
  26.           below  then  it is used by exec to control the flow of input
  27.           and output among the subprocess(es).   Such  arguments  will
  28.           not  be  passed to the subprocess(es).  In forms such as ``<
  29.           fileName'' fileName may either be  in  a  separate  argument
  30.           from ``<'' or in the same argument with no intervening space
  31.           (i.e. ``<fileName'').
  32.  
  33.           |              Separates distinct commands in the  pipeline.
  34.                          The  standard output of the preceding command
  35.                          will be piped into the standard input of  the
  36.                          next command.
  37.  
  38.           |&             Separates distinct commands in the  pipeline.
  39.                          Both  standard  output  and standard error of
  40.                          the preceding command will be piped into  the
  41.                          standard  input  of  the  next command.  This
  42.                          form of redirection overrides forms  such  as
  43.                          2> and >&.
  44.  
  45.           < fileName     The file named by fileName is opened and used
  46.                          as  the  standard input for the first command
  47.                          in the pipeline.
  48.  
  49.           <@ fileId      FileId must be the  identifier  for  an  open
  50.                          file,  such as the return value from a previ-
  51.                          ous call to open.  It is used as the standard
  52.                          input  for the first command in the pipeline.
  53.                          FileId must have been opened for reading.
  54.  
  55.           << value       Value is passed to the first command  as  its
  56.                          standard input.
  57.  
  58.           > fileName     Standard output  from  the  last  command  is
  59.                          redirected   to   the  file  named  fileName,
  60.                          overwriting its previous contents.
  61.  
  62.           2> fileName    Standard error from all commands in the pipe-
  63.                          line   is   redirected   to  the  file  named
  64.                          fileName, overwriting its previous contents.
  65.  
  66.           >& fileName    Both standard output from  the  last  command
  67.                          and  standard  error  from  all  commands are
  68.                          redirected  to  the  file   named   fileName,
  69.                          overwriting its previous contents.
  70.  
  71.           >> fileName    Standard output  from  the  last  command  is
  72.                          redirected   to   the  file  named  fileName,
  73.                          appending to it rather than overwriting it.
  74.  
  75.           2>> fileName   Standard error from all commands in the pipe-
  76.                          line   is   redirected   to  the  file  named
  77.                          fileName,  appending  to   it   rather   than
  78.                          overwriting it.
  79.  
  80.           >>& fileName   Both standard output from  the  last  command
  81.                          and  standard  error  from  all  commands are
  82.                          redirected  to  the  file   named   fileName,
  83.                          appending to it rather than overwriting it.
  84.  
  85.           >@ fileId      FileId must be the  identifier  for  an  open
  86.                          file,  such as the return value from a previ-
  87.                          ous call to open.  Standard output  from  the
  88.                          last  command is redirected to fileId's file,
  89.                          which must have been opened for writing.
  90.  
  91.           2>@ fileId     FileId must be the  identifier  for  an  open
  92.                          file,  such as the return value from a previ-
  93.                          ous call to open.  Standard  error  from  all
  94.                          commands  in  the  pipeline  is redirected to
  95.                          fileId's  file.   The  file  must  have  been
  96.                          opened for writing.
  97.  
  98.           >&@ fileId     FileId must be the  identifier  for  an  open
  99.                          file,  such as the return value from a previ-
  100.                          ous call to open.  Both standard output  from
  101.                          the  last command and standard error from all
  102.                          commands are  redirected  to  fileId's  file.
  103.                          The file must have been opened for writing.
  104.  
  105.           If standard output has not been  redirected  then  the  exec
  106.           command returns the standard output from the last command in
  107.           the pipeline.  If any of the commands in the  pipeline  exit
  108.           abnormally or are killed or suspended, then exec will return
  109.           an error and the error message will include  the  pipeline's
  110.           output  followed  by  error messages describing the abnormal
  111.           terminations; the errorCode variable will contain additional
  112.           information about the last abnormal termination encountered.
  113.           If any of the commands writes to its standard error file and
  114.           that  standard error isn't redirected, then exec will return
  115.           an error;  the error message  will  include  the  pipeline's
  116.           standard  output, followed by messages about abnormal termi-
  117.           nations (if any), followed by the standard error output.
  118.  
  119.           If the last character of the result or error  message  is  a
  120.           newline  then  that  character  is normally deleted from the
  121.           result or error message.  This is consistent with other  Tcl
  122.           return values, which don't normally end with newlines.  How-
  123.           ever, if -keepnewline is specified then the trailing newline
  124.           is retained.
  125.  
  126.           If standard input isn't redirected with ``<'' or  ``<<''  or
  127.           ``<@''  then the standard input for the first command in the
  128.           pipeline is taken from the  application's  current  standard
  129.           input.
  130.  
  131.           If the last arg is ``&'' then the pipeline will be  executed
  132.           in  background.  In this case the exec command will return a
  133.           list whose elements are the process identifiers for  all  of
  134.           the  subprocesses in the pipeline.  The standard output from
  135.           the  last  command  in  the  pipeline   will   go   to   the
  136.           application's  standard output if it hasn't been redirected,
  137.           and error output from all of the commands  in  the  pipeline
  138.           will  go  to  the  application's  standard error file unless
  139.           redirected.
  140.  
  141.           The first word in each command is taken as the command name;
  142.           tilde-substitution  is  performed  on  it, and if the result
  143.           contains  no  slashes  then  the  directories  in  the  PATH
  144.           environment  variable  are searched for an executable by the
  145.           given name.  If the name contains a slash then it must refer
  146.           to  an  executable reachable from the current directory.  No
  147.           ``glob'' expansion or  other  shell-like  substitutions  are
  148.           performed on the arguments to commands.
  149.  
  150.  
  151.      KEYWORDS
  152.           execute, pipeline, redirection, subprocess
  153.